package com.easidea.tim.util;


public class ParamsUtilities {
	private ParamsUtilities() {
	}

	/**
	 * Replace reserved char of sql.
	 * 
	 * @param str
	 * @return
	 */
	public static String dealWithReservedSqlChar(String str) {
		String result = str;
		if (!isNullOrBlank(str)) {
			result = result.replace("\\", "\\\\");
			result = result.replace("\'", "\\'");
			result = result.replace("%", "\\%");
			result = result.replace("_", "\\_");
		}
		return result;
	}
	/**
	 * 判断字符串是否为null或空恪
	 * 
	 * @param str
	 * @return
	 */
	public static boolean isNullOrBlank(String str) {
		if (str == null || str.trim().equals("")) {
			return true;
		}
		return false;
	}
	/**
	 * 生成序号
	 * @param <T>
	 * @param num 位数
	 * @param t 
	 * @return
	 */
	public static <T> String createCode(int num,T t){
		if(t == null){ return "";}
		String code = t.toString();
		num = num - code.length();
		for(int i=0;i<num;i++){
			code = "0"+code;
		}
		return code;
	}
}
